﻿var bullet_img;
var player_img, player_imgx, player_imgy;
var enemy_img, enemy_imgx, enemy_imgy;

function image_init() {
    bullet_img = [];
    bullet_img[0] = document.getElementById('bullet_img_0');
    bullet_img[3] = document.getElementById('bullet_img_3');
    
    player_img = document.getElementById('player_img');
    player_imgx = [0, 32, 64, 96, 128, 160, 192, 224,
                    0, 32, 64, 96, 128, 160, 192, 224,
                    0, 32, 64, 96, 128, 160, 192, 224,];
    player_imgy = [0, 0, 0, 0, 0, 0, 0, 0, 
                    48, 48, 48, 48, 48, 48, 48, 48,
                    96, 96, 96, 96, 96, 96, 96, 96];
    
    enemy_img = [];
    enemy_imgx = [];
    enemy_imgy = [];
    enemy_img[0] = document.getElementById('enemy_img');
    enemy_imgx[0] = [0, 32, 64, 0, 32, 64, 0, 32, 64];
    enemy_imgy[0] = [0, 0, 0, 32, 32, 32, 64, 64, 64];
    
    item_img = document.getElementById('item_img');
    
    bg_img = document.getElementById('bg_img');
    
}

function player_bullet_draw_0() {
    context.drawImage(bullet_img[2], this.x - 3, this.y - 18);
}

function bullet_draw_0() {
    context.drawImage(bullet_img[0], 0, 0, 16, 16, this.x - 8, this.y - 8, 16, 16);
}

function bullet_draw_1() {
    context.save();
    context.translate(this.x, this.y);
    context.rotate(this.ang + pi * 0.5);
    context.drawImage(bullet_img[0], 0, 16, 16, 16, -8, -8, 16, 16);
    context.restore();
}

function bullet_draw_2() {
    context.save();
    context.translate(this.x, this.y);
    context.rotate(this.ang + pi * 0.5);
    context.drawImage(bullet_img[0], 0, 32, 16, 16, -8, -8, 16, 16);
    context.restore();
}

function bullet_draw_3() {
    context.save();
    context.translate(this.x, this.y);
    context.rotate(this.ang + pi * 0.5);
    context.drawImage(bullet_img[0], 0, 48, 16, 16, -8, -8, 16, 16);
    context.restore();
}

function item_draw_0() {
    context.drawImage(item_img, 0, 0, 16, 16, this.x - 8, this.y - 8, 16, 16);
}

function item_draw_1() {
    context.drawImage(item_img, 16, 0, 16, 16, this.x - 8, this.y - 8, 16, 16);
}